package com.micro.plugins.oss.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * <h1>oss对象存储枚举类</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020/5/8
 */
@Getter
@AllArgsConstructor
public enum OssRuleFlag {

    /**
     * 七牛云
     */
    OSS_SERVICE_PROVIDER_QINIUYUN("qiniu-cloud","七牛云存储"),

    /**
     * 阿里云
     */
    OSS_SERVICE_PROVIDER_ALIYUN("ali-cloud","阿里云存储"),

    /**
     * 腾讯云
     * code:tencent-cloud
     * description:腾讯云存储
     */
    OSS_SERVICE_PROVIDER_QCLOUD("tencent-cloud","腾讯云存储");

    /**
     * 云存储规则编码
     */
    private String code;

    /**
     * 云存储规则描述信息
     */
    private String description;

    public static OssRuleFlag of(String code){
        Objects.requireNonNull(code);
        return Stream.of(values())
                .filter(bean -> bean.code.equals(code))
                .findAny()
                .orElseThrow(() -> new IllegalArgumentException(code +"not exists"));
    }



}
